﻿#ifndef STAGECONTROLDOCKWIDGET_H
#define STAGECONTROLDOCKWIDGET_H

#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QDockWidget>
#include "XYControlGroupBox.h"
#include "ZControlGroupBox.h"
#include "PositionGroupBox.h"

class LimitGroupBox;

class StageControlDockWidget : public QDockWidget
{
    Q_OBJECT
public:
    StageControlDockWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
    void initContent();
    void initConnection();
    double xySpeed();
    double zSpeed();
public slots:
    //void workingDirEnable(bool on);
    void xySpeedUp();
    void xySpeedDown();
    void zSpeedUp();
    void zSpeedDown();

    void joystick_moveUp(); // 之所以有这些 SLOT 是因为 joystick 不知道运动速度。需要从这里获得运动速度。
    void joystick_moveDown();
    void joystick_moveForward();
    void joystick_moveBackward();
    void joystick_moveLeft();
    void joystick_moveRight();
//    void joystick_stopX();
//    void joystick_stopY();
//    void joystick_stopZ();
    void setXPosition(double x);
    void setYPosition(double y);
    void setZPosition(double z);
    void setPosition(double x, double y, double z);
    void setLimitState(int axis, int llimit, int home, int rlimit);
    void enableXYControl(bool on);
signals:
    void moveForward(double mmps);
    void moveBackward(double mmps);
    void moveLeft(double mmps);
    void moveRight(double mmps);

    void moveForwardLeft(double mmps);
    void moveBackwardLeft(double mmps);
    void moveBackwardRight(double mmps);
    void moveForwardRight(double mmps);

    void moveForwardStop();
    void moveBackwardStop();
    void moveLeftStop();
    void moveRightStop();
    void moveUp(double mmps);
    void moveDown(double mmps);
    void moveUpStop();
    void moveDownStop();
    void stopX();
    void stopY();
    void stopXY();
    void stopZ();

    void goHomeX();
    void goHomeY();
    void goHomeZ();

    void showFastMoveDialog();
    void gotoHomePos();

    void changeXYSpeed(double mmps);
    void changeZSpeed(double mmps);

private:
    XYControlGroupBox *xyControl;
    ZControlGroupBox *zControl;
    PositionGroupBox *xyPosGB;
    LimitGroupBox * limitDisplay;

    QPushButton *pushButtonGoHomeX;
    QPushButton *pushButtonGoHomeY;
    QPushButton *pushButtonGoHomeZ;
    QPushButton *pushButtonFastMove;
    QPushButton *pushButtonHomePos;
    QVBoxLayout *goHomeLayout;
    QGroupBox *goHomeGroupBox;

    QHBoxLayout *horizontalLayout;
    QWidget *dockWidget;
    QVBoxLayout *vLayout;
};

#endif // STAGECONTROLDOCKWIDGET_H
